{% extends "base.html" %} {% block head %} {{ super() }}

<script src="{{url_for('static', filename='../static/js/zform.js')}}" type="text/javascript" charset="utf-8"></script>
<script src="{{url_for('static', filename='../static/js/ztable.js')}}" type="text/javascript" charset="utf-8"></script>
<script>
	$(document).ready(function(){
		var form = $('#company-form').ZForm({height:300,
				errors:{{ errors_json | safe }}
			});
		
		function select_row($row){
			company_name = $row.find('td[name="name"]').attr('value');
			$("#manage-menu-btn").attr('href','/manage_items/' + company_name);
		}

		var $Table = $('#company-table').ZTable({select_row_cb:select_row});
	});
	
</script>

<title>Manage Companies</title>

{% endblock %}

{% block left_area %}
	{{ super() }}
	<div class="left-side-content">
		{% if user['role'] == 0 %}
		<div><a href="#">My Profile</a></div>
		{% elif user['role'] == 1 %}
		<div><a href="#">My Profile</a></div>
		<div><a href="/user_manager">User Management</a></div>
		{% endif%}
	</div>

{% endblock %}

{% block content %}

	<form id="company-form" action="/submit_company" method="post">
		<div class="row form-group" name="name">
			<div class="col-md-5">
				<input class="form-control z-input" type="text" placeholder="{{ 'Company Name' }}" />
			</div>
			<div class="col-md-5">
				<div class="z-label">{{ 'Company Name' }}</div>
			</div>
		</div>

		<div class="row form-group" name="description">
			<div class="col-md-5">
				<textarea class="form-control z-input" rows="5" placeholder="{{ 'Description' }}"></textarea>
			</div>
			<div class="col-md-5">
				<div class="z-label">{{ 'Description' }}</div>
			</div>
		</div>

		<!-- Street -->
		<div class="row form-group" name="street">
			<div class="col-md-5">
				<input class="form-control" type="text" placeholder="{{ 'Street No. and Street Name' }}" />
			</div>
			<div class="col-md-4">{{ 'Street No. and Street Name' }}</div>
		</div>

		<!-- Postal code -->
		<div class="row form-group" name="postcode">
			<div class="col-md-5">
				<input class="form-control" type="text" placeholder="{{ 'Postcode' }}" />
			</div>
			<div class="col-md-4">{{ 'Postcode' }}</div>
		</div>

		<input class="hide" type="text" name="mode" value="new"/>

		<div class="row col-md-11">
			<div class="btn-toolbar col-md-7 z-btn-area">
				<button type="submit" class="z-submit-btn submit btn btn-primary col-md-2">Submit</button>
			</div>
		</div>
	</form>

		<br/>
		<div class="btn-toolbar col-md-12 z-btn-area">
			<a id="manage-menu-btn" href="" class="btn btn-primary col-md-2">{{'Manage Menus'}}</a>
		</div>

		<form id="company-list-form" action="/manage_companies" method="post">
			<div class="panel-body">

				<div>
					<table id="company-table" class="table" mode="normal"
						style="height: 200px; overflow: auto;">
						<tbody>
							{% if companies !=[] %}
								{% if user['role'] == "0" %}
									{% for company in companies %}
										<tr>
											<td name="name" value="{{company['name']}}">{{company['name']}}</td>
											<td name="street">{{company['street']}}</td>
										</tr>
									{% endfor %}								
								{% else %}
									{% for company in companies %}
										<tr>
											<td><input type="checkbox" name="selected" value="{{ None }}"></td>
											<td name="name" value="{{company['name']}}">{{company['name']}}</td>
											<td name="street">{{company['street']}}</td>
										</tr>
									{% endfor %}
								{% endif %}
							{% endif %}
						</tbody>
					</table>
				</div>
				<br />
				<p>Rows 1-10 of 48</p>
			</div>

		</form>

{% endblock %}

{% block right_area %}
	<div class="right-side-area col-md-2">
	
	</div>
{% endblock %}